<?php
session_start();

if(isset($_POST['submit'])){
    
    $id = $_POST['deleteID'];
    
    include 'DBLibrary/config.php';
    include 'DBLibrary/openDB.php';

    mysql_select_db("rotaract");
    
    $query="DELETE FROM officer WHERE accountID = $id";
    $result = mysql_query($query)or die(mysql_error());
    
    $confirm="Deletion successful!";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Rotaract DLSU</title>
<meta http-equiv="Content-Type" content="text/html"/>
<meta name="robots" content="index,follow"/>
<meta name="distribution" content="global"/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="container2">
  <div id="main3">
    <table width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td class="main_nav">
            <div id="main_text2"> 
          <center>
              <h2>Delete an Officer</h2>
              
                      <?
    if (isset($confirm)) {
                                            
        echo "<br/>";
        echo "<h3>$confirm</h3>";
        echo "<br/>";
     }
    ?>
              <?
include 'DBLibrary/config.php';
include 'DBLibrary/openDB.php';

    mysql_select_db("rotaract");
   $query = "SELECT * FROM officer";
    $result = mysql_query($query)or die(mysql_error());
   ?><table border ="1" cellpadding="10" class="myTable">
    <tr>
        <td><b>ID</b></td>
        <td><b>First name</b></td>
        <td><b>Last name</b></td>
        <td><b>Username</b></td>
        <td><b>E-Mail</b></td>
        <td><b>Position</b></td>
    </tr>
        <br/>
        <br/>
    <?
    while($row = mysql_fetch_array($result)){
        $id = $row['accountID'];
        $fname = $row['firstName'];
        $lname = $row['lastName'];
        $username = $row['username'];
        $email = $row['email'];
        $position = $row['position'];
       
            echo ' <tr>';
            echo '     <td>'.$id.'</td>';
            echo '     <td>'.$fname.'</td>';
            echo '     <td>'.$lname.'</td>';
            echo '     <td>'.$username.'</td>';
            echo '     <td>'.$email.'</td>';
            echo '     <td>'.$position.'</td>';
            echo '</tr>';

        
    }
              ?>
        </table>
        <br/>
        <br/>
              <form action="RAC-DeleteUser.php" method="POST" >
              <h6>Enter the ID of the user that you would want to delete.</h6>
              <input type="text" name="deleteID"/>
              <input type="submit" name="submit" value="Delete" onclick="confirm('Are you sure you wish to continue?')"/>
              </form>
          </center>
          </div>
          </td>
        
      </tr>
    </table>
  </div>
</div>
</body>
</HTML>
